const Router = require('@koa/router');

const router = new Router();

module.exports = router;

router.get('/', async (ctx, next) => {
  const { appName } = process.env;
  const { user } = ctx.session;
  if (!user || !user.id) {
    ctx.redirect('/auth/login');
    return;
  }

  await ctx.render('home', { user, appName });
  next();
});
